#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/string.h>

#define MAX_SLAM_SIZE 5
#define MAX_SLAM_STRING_LEN 16

static int slam_boot_int;
static int slam_boot_int_array[MAX_SLAM_SIZE];
static char slam_boot_string[MAX_SLAM_STRING_LEN];

static int __init slam_parse_int(char *s)
{
	int ret;

	ret = get_option(&s, &slam_boot_int);
	if(ret == 1)
	      printk("slam_boot_int=%d\n", slam_boot_int);
	return 1;
}

static int __init slam_parse_int_array(char *s)
{
	char * ret_slam_str;
	int i;

	ret_slam_str = get_options(s, MAX_SLAM_SIZE, slam_boot_int_array);
	if(*ret_slam_str != '\0')
	{
		printk("incorrect slam_boot_int_array parameters: %s\n", ret_slam_str);
	}
	else
	{
		printk("slam_boot_int_array=");
		for(i=1; i<MAX_SLAM_SIZE; i++)
		{
			printk("%d",slam_boot_int_array[i]);
			if(i<(MAX_SLAM_SIZE-1))
			      printk(",");
		}
		printk("\n");
		printk("slam_boot_int_array includes %d intergers\n", i);
	}
	return 1;
}

static int __init slam_parse_string(char *s)
{
	if(strlen(s) > MAX_SLAM_STRING_LEN)
	{
		printk("Too long slam_boot_string parameter!\n");
		printk("Maximum length is less than or equal to %d\n", MAX_SLAM_STRING_LEN);
	}
	else
	{
		memcpy(slam_boot_string, s, strlen(s)+1);
		printk("slam_boot_string=%s\n", slam_boot_string);
	}
	return 1;
}

__setup("slam_boot_int=", slam_parse_int);
__setup("slam_boot_int_array=", slam_parse_int_array);
__setup("slam_boot_string=", slam_parse_string);
